<!--
 入参：
 category： 类别，对应DocCategory编码
-->
<template>
  <div>
    <div class="tl-form-line-title">
      流程文件
    </div>
    <div style="padding-left:15px;">
      <div class="toolbar">
        <el-badge :value="count" class="item">
          <el-button type="primary" size="small" plain @click.native="openFileListDialog('fileDialog')">流程文件</el-button>
        </el-badge>
      </div>
      <file-dialog ref="fileDialog" type="list" :category="category"></file-dialog>
    </div>
  </div>
</template>

<script>
/** mixins */
import { mixin_list } from "@tapui/mixins/mixin_list"
/** 子组件 */
import fileDialog from "./dialog"
/** 工具类 */
import { getAction, putAction } from "@tapui/utils/http"

/** VUE配置 */
export default {
  mixins: [mixin_list],
  components: { fileDialog },
  data() {
    return {
      moduleTitle: "文档配置",
      urlPrefix: "/base/processDocumentInfo/",
      url: {
        count: '/base/processDocumentInfo/queryProcessDocNum'
      },
      model: {},
      isQueryOnCreated: false,
      tableHeight: 0,
      sourceType: "",
      count: 0
    }
  },
  props: {
    category: {
      default: '',
      type: String
    }
  },
  methods: {
    openFileListDialog(editForm) {
      this.$refs[editForm].visible = true
    }
  },
  mounted() {
    let params = {
      category: this.category
    }
    getAction(this.url.count, params)
      .then((res) => {
        if (res.success) {
          this.count = res.result.count
        } else {
          this.$tap.alert(res.message, "warning")
        }
        if (this.count === 0) {
          this.visible = false
          return
        }
        this.visible = true
      })
      .catch(() => {})
  },
  created() {}
}
</script>
<style scoped></style>
